package voice.main;

import object.Command.CommandType;
import util.CommandManager;
import voice.main.R;
import adapter.MenuItemAdapter;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.view.View;

public class MainMenuActivity extends Activity {
	 
	ListView listView;
 
	static final String[] MENU_ITEMS = new String[] { 
		"Chat with YRU", "Phone", "SMS", "Open Map", "Get Current Location", 
		"Open Email", "Toggle Wifi", "Toggle Cellular", "Toggle Bluetooth",
		"Open Camera", "Open Web Browser", "Open Facebook", "Open Skype" };
 
	@Override
	public void onCreate(Bundle savedInstanceState) {
 
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_menu);
 
		listView = (ListView) findViewById(R.id.menuListView);
 
		listView.setAdapter(new MenuItemAdapter(this, MENU_ITEMS));
 
		listView.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
				String item = ((TextView) v.findViewById(R.id.list_item_label)).getText().toString();
				CommandManager commandManager = CommandManager.getInstance(getApplicationContext());
				if (item.equals("Chat with YRU")) {
					Intent intent = new Intent(getApplicationContext(), ChatActivity.class);
			    	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			    	getApplicationContext().startActivity(intent);
				}
				else if (item.equals("Phone")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Call, "");
				}
				else if (item.equals("SMS")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.SMS, "");
				}
				else if (item.equals("Open Map")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Address, "");
				}
				else if (item.equals("Get Current Location")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Location, "");
				}
				else if (item.equals("Open Email")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Mail, "");
				}
				else if (item.equals("Toggle Wifi")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Wifi, "");
				}
				else if (item.equals("Toggle Cellular")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Cellular, "");
				}
				else if (item.equals("Toggle Bluetooth")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Bluetooth, "");
				}
				else if (item.equals("Open Camera")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Camera, "");
				}
				else if (item.equals("Open Web Browser")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Web, "");
				}
				else if (item.equals("Open Facebook")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Facebook, "");
				}
				else if (item.equals("Open Skype")) {
					commandManager.executeCommand(getApplicationContext(), CommandType.Skype, "");
				}
			}
		});
 
	}
 
}